import pyttsx3

# 创建pyttsx3的引擎对象
engine = pyttsx3.init()

# 设置语音属性
engine.setProperty('rate', 180)  # 语速，默认为200，可调整为更小的值（如150）
engine.setProperty('volume', 1)  # 音量，默认为1，可调整为0到1之间的浮点数

# 文本内容
text = "你好，我是小助手。"

# voice_text_dict = {
#     "open_door": "门已打开，请听到关门提示语音在离开货柜",
#     "close_door": "门已关闭，开始盘点购物数量",
#     "inventory_completed": "盘点结束, 请核对购物数量",
#     "start_restocking": "开始补货",
#     "end_restocking": "补货完成请确认补货数量"
# }

voice_text_dict = {
    "open_door": "门已打开",
    "close_door": "门已关闭",
    "inventory_completed": "统计完成",
    "start_restocking": "开始补货",
    "end_restocking": "补货完成请确认补货数量"
}


for key, value in voice_text_dict.items():

    # 生成语音
    engine.save_to_file(value, "{}.mp3".format(key))

engine.runAndWait()